package com.supconit.controller;


import com.supconit.entity.Content;
import com.supconit.service.IContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
    *  前端控制器
    * </p>
 *
 * @author xjh
 * @since 2019-08-17
 */
@RestController
@RequestMapping("/vote/content")
@Api(description = "")
public class ContentController extends BaseController {

    @Autowired
    private IContentService contentService;

    /**
     * 列表
     */
    @PostMapping(value = "/list")
    @ApiOperation(value = "列表", notes = "列表")
    public Object list() {
        QueryWrapper<Content> wrapper = new QueryWrapper<>();
        return contentService.list(wrapper);
    }

     /**
     * 分页
     */
    @PostMapping(value = "/page")
    @ApiOperation(value = "分页", notes = "分页")
    public Object page(Page<Content> page) {
        QueryWrapper<Content> wrapper = new QueryWrapper<>();
        return contentService.page(page, wrapper);
    }

    /**
     * 详情
     */
    @GetMapping(value = "/getById/{id}")
    @ApiOperation(value = "详情", notes = "详情")
    public Object getById(@PathVariable("id") Long id) {
        return contentService.getById(id);
    }

     /**
     * 新增
     */
    @PostMapping(value = "/save")
    @ApiOperation(value = "新增", notes = "新增")
    public Object save(Content content) {
        content.setId(null);
        return contentService.save(content);
    }

    /**
     * 删除
     */
    @PostMapping(value = "/removeById")
    @ApiOperation(value = "删除", notes = "删除")
    public Object removeById(@RequestParam Long id) {
        return contentService.removeById(id);
    }

    /**
     * 修改
     */
    @PostMapping(value = "/updateById")
    @ApiOperation(value = "修改", notes = "修改")
    public Object updateById(Content content) {
        return contentService.updateById(content);
    }
}
